//
//  MainTabBarController.swift
//  传智小微博
//
//  Created by lxgoodgo on 16/4/17.
//  Copyright © 2016年 liux.orz. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let  tabBar = MainTabBar()
        tabBar.delegate = self
        //只能这么 设置 自定义TabBar
        setValue(tabBar, forKey: "tabBar")
        let homeTc = HomeTableController()
        let disTc = DiscoverTableController()
        let messTc = MessageTableController()
        let profileTc = ProfileTableController()
        
        addChildViewController(homeTc, title: "首页", imgName: "tabbar_home")
        addChildViewController(messTc, title: "消息", imgName: "tabbar_message_center")
        addChildViewController(disTc, title: "发现", imgName: "tabbar_discover")
        addChildViewController(profileTc, title: "我的", imgName: "tabbar_profile")
        
        
        
    }
    
    //
    func addChildViewController(childController: UIViewController,title: String,imgName: String) {
        
        childController.tabBarItem.image = UIImage(named: imgName)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")
        
        childController.title = title
        addChildViewController(UINavigationController(rootViewController: childController))
        
        
        
        
    }
  
}

extension MainTabBarController : TabBarDelegate
{
    
    func composeButtonClick() {
        print("撰写按钮")
        print("composeButtonClick")
    }
}




